﻿//此接口服务暂停
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Configuration;
using UFC.Common;

namespace MESMaterialToolsAuxMaterial
{
    public partial class Send_MaterialToolsAuxMaterialToErp : ServiceBase
    {
        public Send_MaterialToolsAuxMaterialToErp()
        {
            InitializeComponent();
        }

        private System.Timers.Timer m_SyncTimer;
        protected override void OnStart(string[] args)
        {
            LogHelp.SetConfig();
            m_SyncTimer = new System.Timers.Timer();
            m_SyncTimer.Enabled = false;
            m_SyncTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_SyncTimer_Elapsed);

            int intSync = Convert.ToInt32(ConfigurationManager.AppSettings["sync"].ToString());
            m_SyncTimer.Interval = intSync * 20 * 1000;
            m_SyncTimer.Enabled = true;
            m_SyncTimer.Start();
        }
        private void m_SyncTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                LogHelp.WriteLog("MaterialToolsAuxMaterial定时器启动");
                m_SyncTimer.Enabled = false;
                SendMaterialToolsAuxMaterialToErp smtzm_ToErp = new SendMaterialToolsAuxMaterialToErp();
                smtzm_ToErp.RunMaterialToolsAuxMaterialSync();
            }
            catch (Exception myError)
            {
                LogHelp.WriteError("MaterialToolsAuxMaterial定时器启动", myError);
            }
            finally
            {
                m_SyncTimer.Enabled = true;
            }
        }
        protected override void OnStop()
        {
        }
    }
}
